home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_riv_candelabra.cog < prev    next >
Text File  |  1999-11-15  |  31KB  |  1,255 lines

  1. # Jones 3D Cog Script
  2. #
  3. # Riv_Candelabra.cog
  4. #
  5. # candlea = 88
  6. # candleb = 89
  7. # candlec = 90
  8. # candled = 91
  9. #
  10. # [TRM & revised by HB]
  11. #
  12. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  13. # ==============================================================================
  14.  
  15. symbols
  16.  
  17.     message        startup
  18.     message     entered
  19.     message     activated
  20.     message        user0
  21.  
  22.     # ** misc local things **
  23.     thing       player          local
  24.     thing       indy            local
  25.     thing        camindy            local
  26.     thing        offsetcam        local
  27.     thing       candleA         local
  28.     thing       candleB         local
  29.     thing       candleC         local
  30.     thing       candleD         local
  31.     thing       bridge_Anim     local
  32.     thing       exit_Bridge     local
  33.     thing       wind_Flag1      local
  34.     thing       wind_Flag2      local
  35.     
  36.     # ** misc things **
  37.     thing       candelabra
  38.     thing       windmill        nolink
  39.     thing        tower            nolink
  40.     thing       bridge
  41.     thing       bridge2
  42.     thing        centerspot        nolink
  43.     
  44.     # ** candle holders **
  45.     thing       candleArm_N     linkID=2
  46.     thing       candleArm_S     linkID=2
  47.     thing       candleArm_E     linkID=2
  48.     thing       candleArm_W     linkID=2
  49.  
  50.     # ** candle holder positions **
  51.     thing       candlePos_N        nolink
  52.     thing       candlePos_S        nolink
  53.     thing       candlePos_E        nolink
  54.     thing       candlePos_W        nolink
  55.     thing        candlepos_X        local # var
  56.     
  57.     # ** camera offsets **
  58.     thing       offset_N        nolink
  59.     thing       offset_S        nolink
  60.     thing       offset_E        nolink
  61.     thing       offset_W        nolink
  62.     thing        offset_L        local # var
  63.     
  64.     # ** snow devils **
  65.     thing       devil0            nolink
  66.     thing       devil1            nolink
  67.     thing       devil2            nolink
  68.     thing       devil3            nolink
  69.     
  70.     # ** fourwinds cutscene things **
  71.     thing       wm_cam_1        nolink
  72.     thing       wm_cam_2        nolink
  73.     thing       wm_cam_3        nolink
  74.     thing       wm_cam_4        nolink
  75.     thing       wm_cam_5        nolink
  76.     thing       wm_ct_1            nolink
  77.     thing       wm_ct_2            nolink
  78.     thing       wm_ct_3            nolink
  79.     thing       wm_ct_4            nolink
  80.     thing       wm_ct_5            nolink
  81.     thing        wm_ct_6            nolink
  82.     thing        wm_mk_1            nolink
  83.     thing        wm_mk_2            nolink
  84.     thing       wm_mk_3            nolink
  85.     thing       fadePlate        nolink
  86.     thing        camspot            nolink
  87.     thing        camlookspot        nolink
  88.     thing       flag1           nolink
  89.     thing       flag2           nolink
  90.         
  91.     # ** cogs **
  92.     cog            northcandlecog
  93.     cog            southcandlecog
  94.     cog            eastcandlecog
  95.     cog            westcandlecog
  96.     cog            somecandlecog=0                    local # var
  97.     cog         hintCog
  98.  
  99.     # ** sectors **
  100.     sector      sec0
  101.     sector        camsector                        local # var
  102.     
  103.     # ** templates **
  104.     template    tpl_CandleA=cndlamove           local
  105.     template    tpl_CandleB=cndlbmove           local
  106.     template    tpl_CandleC=cndlcmove           local
  107.     template    tpl_CandleD=cndldmove           local
  108.     template    tpl_BridgeAnim=rivbridge        local
  109.     template    tpl_BridgeStill=rivbrdgstll     local
  110.     template    tpl_Indy=indy_actor             local
  111.     template    tpl_Devil=skitodevil            local
  112.     template    tpl_LilDevil=lilskitodevil      local
  113.     template    tpl_ghost=ghost                    local
  114.     template    tpl_WindFlag=markredwind        local
  115.     
  116.     # ** keyframes **
  117.     keyframe    key_Gears=riv_gears.key                local
  118.     keyframe    key_Bridge=riv_bridge_anim.key        local
  119.     keyframe    in_think=0in_thinking_4_4.key        local # 150x
  120.     keyframe    in_sideTOhips=0in_stand1_bd_4.key    local
  121.     keyframe    in_handsONhips=0in_stand4.key        local
  122.     keyframe    in_botharmsup=0in_armsup_1_1.key    local
  123.     keyframe    in_rtarmup=0in_armsout_1_1.key        local
  124.     keyframe    key_Flag=riv_markred_wind.key       local
  125.       
  126.     # ** candelabra voice lines **
  127.     sound       say_Candelabra=Rv05j02.wav      local # it looks like a candle holder...
  128.     sound       say_pray1=Rv05j03.wav           local # pray to the four winds
  129.     sound       say_Pray2=Rv05j04.wav           local # ...okay, I'm praying.  Now what?
  130.     
  131.     # ** success lines **
  132.     sound        in_Success0=Inxj110.wav            local # Success!
  133.     sound        in_Success1=Inxj108.wav            local # There!
  134.     sound        in_Success2=Inxj109.wav            local # It fits!
  135.     sound        in_Success3=Inxj112.wav            local # That ought to do it!
  136.     
  137.     # ** using the wrong or no item lines **
  138.     sound        in_WrongItem0=Inxj089.wav       local # That didn't work
  139.     sound        in_WrongItem1=Inxj090.wav        local # ...something wrong.
  140.     sound        in_WrongItem2=Inxj092.wav        local # Hmm...didn't quite work.
  141.     sound        in_WrongItem3=Inxj088.wav        local # Nope.
  142.     sound        in_WrongItem4=Inxj061.wav        local # Not sure good idea.
  143.     
  144.     # ** standing on the wrong spot lines **
  145.     sound        in_WrongSpot0=Inxj060.wav        local # I don't think...right answer
  146.     sound        in_WrongSpot1=Inxj095.wav        local # Must be a different way
  147.     sound        in_WrongSpot2=Inxj058.wav        local # That won't work.
  148.     
  149.     # ** misc sounds **
  150.     sound       sfx_Gust0=riv_wind_gust_small.wav       local # small wind sound
  151.     sound       sfx_Gust1=riv_wind_gust_big.wav         local # big wind sound
  152.     sound       say_Strange=Rv05j01.wav                 local # strange place for a windmill
  153.     sound        say_worked=Inxj111.wav                    local # What know it worked    
  154.     
  155.     # ** sound fx **
  156.     sound       sfx_Start=riv_bridge_start_c.wav        local
  157.     sound       sfx_Move=riv_bridge_move_c.wav          local
  158.     sound       sfx_Stop=riv_bridge_stop_c.wav          local
  159.     sound       sfx_Gears=riv_windmill_gears_c.wav      local
  160.     
  161.     # ** music **
  162.     sound       mus_Cue1=mus_riv_windmillcutscene.wav   local
  163.     sound       mus_Cue2=mus_riv_endlevel.wav           local
  164.         
  165.     # ** subroutines **
  166.     flex        placecandle            local
  167.     flex        lightcandle            local
  168.     flex        fourWinds           local
  169.     flex        endCut              local
  170.     flex        speak_Success       local
  171.     flex        speak_Item          local
  172.     flex        speak_Wrong         local 
  173.     flex        backtoplay            local 
  174.  
  175.     # ** vector vars **
  176.     vector        v_clvec                local
  177.     vector        v_crvec                local
  178.     vector        v_aimci                local
  179.     vector        v_slewoff            local
  180.     vector        v_aimcam            local
  181.     vector        v_campos            local
  182.     vector        v_cam1pos            local
  183.     vector        v_cam1lookpos        local
  184.  
  185.     # ** flex vars **
  186.     flex        viewangle            local
  187.     flex        f_dotl                local
  188.     flex        f_dotr                local
  189.  
  190.     # ** cardinal ints **
  191.     int         spot=0              local
  192.     int            spot45=0            local
  193.     int         north=1             local
  194.     int         south=2             local
  195.     int         east=3              local
  196.     int         west=4              local
  197.     
  198.     # ** misc ints **
  199.     int         curItem=0           local
  200.     int         curWeap=0           local
  201.     int         playing=0           local
  202.     int         placed_Count=0      local
  203.     int         lit_Count=0         local
  204.     int         done=0              local
  205.     int         move_Track          local
  206.  
  207.     int            sender                local
  208.     int            sendid                local
  209.     int            sendcog                local
  210.     int            getinfo=0            local
  211.     int            visits=0            local
  212.     int            in_keyTrack1        local
  213.     int            in_keyTrack2        local
  214.     int            wm_keyTrack1        local
  215.     int            wm_sndTrack1        local
  216.     int            curcam                local
  217.     int            cursound            local
  218.     int            offcamexists=0        local
  219.     int            pl_colltype            local
  220.     int            wm_colltype            local
  221.     int            t_colltype            local
  222.     
  223.     int         placed_N=0            local
  224.     int         placed_S=0            local
  225.     int         placed_E=0            local
  226.     int         placed_W=0            local
  227.     
  228.     int         lit_CandleN=0       local
  229.     int         lit_CandleS=0       local
  230.     int         lit_CandleE=0       local
  231.     int         lit_CandleW=0       local
  232.    
  233.     int         newSuccess=0        local
  234.     int         oldSuccess=0        local
  235.     int         newItem=0           local
  236.     int         oldItem=0           local
  237.     int         newWrong=0          local
  238.     int         oldWrong=0          local
  239.     
  240.  end 
  241.  
  242.  
  243. # ==============================================================================
  244.  
  245. code
  246.  
  247. startup:
  248.  
  249.     player = GetLocalPlayerThing();        
  250.     SetThingAlpha(fadePlate, 0.0);
  251.     SetThingFlags(fadeplate, 0x80000);
  252.  
  253.     Print("...candelabracog started...");
  254.     
  255.     return;
  256.     
  257. # ==============================================================================
  258.  
  259. user0:
  260.  
  261.     # Notify when candles blow out...
  262.     
  263.     sendcog = GetSenderRef();
  264.     
  265.     if (sendcog == northcandlecog)
  266.     {
  267.         lit_CandleN = 0;
  268.     }
  269.     if (sendcog == southcandlecog)
  270.     {
  271.         lit_CandleS = 0;
  272.     }
  273.     if (sendcog == eastcandlecog)
  274.     {
  275.         lit_CandleE = 0;
  276.     }
  277.     if (sendcog == westcandlecog)
  278.     {
  279.         lit_CandleW = 0;
  280.     }
  281.  
  282.     # play small wind sound
  283.     PlaySoundLocal(sfx_Gust0, 1.0, 0.0, 0x0, 0);
  284.  
  285.     return;
  286.  
  287. #===============================================================================
  288.  
  289. entered:
  290.   
  291.     if ((GetSenderRef() == exit_Bridge) && (done == 0))
  292.     {
  293.         done = 1;
  294.         Call endCut;
  295.     }
  296.  
  297.     return;
  298.  
  299. #===============================================================================
  300.  
  301. activated:
  302.  
  303.     # Take snapshot...
  304.     curcam = GetCurrentCamera();
  305.     viewangle = GetCameraFOV();
  306.     pl_colltype = GetCollideType(player);
  307.     curItem = GetCurItem(player);
  308.     curWeap = GetCurWeapon(player);
  309.     sender = GetSenderRef();
  310.     sendid = GetSenderID();
  311.  
  312.     # prep cam
  313.     SetCameraLookInterp(2, 0);
  314.     SetCameraPosInterp(2, 0);
  315.  
  316.     # Is player checking candleholders for info?        
  317.     getinfo = 0;
  318.     if (sender == candelabra || sendid == 2)
  319.     {
  320.         getinfo = 1;
  321.     }
  322.     if ((curWeap == 13) && (lit_Count != 4))
  323.     {
  324.         if ((sender == candleArm_N) && (placed_N != 0))
  325.         {
  326.             getinfo = 0;
  327.         }
  328.         if ((sender == candleArm_S) && (placed_S != 0))
  329.         {
  330.             getinfo = 0;
  331.         }
  332.         if ((sender == candleArm_E) && (placed_E != 0))
  333.         {
  334.             getinfo = 0;
  335.         }
  336.         if ((sender == candleArm_W) && (placed_W != 0))
  337.         {
  338.             getinfo = 0;
  339.         }
  340.     }
  341.  
  342.     # Where's player?
  343.     spot = 0;
  344.     v_clvec = GetThingLVec(candelabra);
  345.     v_crvec = GetThingRVec(candelabra);
  346.     v_aimci = VectorSub((GetThingPos(candelabra)), (GetThingPos(player)));
  347.  
  348.     f_dotl = VectorDot(VectorNorm(v_aimci), v_clvec);
  349.     f_dotr = VectorDot(VectorNorm(v_aimci), v_crvec);
  350.  
  351.     if (f_dotl < 0)
  352.     {
  353.         if (f_dotr < 0)
  354.         {
  355.             spot = east;
  356.         }
  357.         else
  358.         {
  359.             spot = north;
  360.         }
  361.     }
  362.     else
  363.     {
  364.         if (f_dotr < 0)
  365.         {
  366.             spot = south;
  367.         }
  368.         else
  369.         {
  370.             spot = west;
  371.         }
  372.     }
  373.  
  374.     spot45 = 0;
  375.     v_clvec = GetThingLVec(centerspot);
  376.     v_crvec = GetThingRVec(centerspot);
  377.     v_aimci = VectorSub((GetThingPos(centerspot)), (GetThingPos(player)));
  378.  
  379.     f_dotl = VectorDot(VectorNorm(v_aimci), v_clvec);
  380.     f_dotr = VectorDot(VectorNorm(v_aimci), v_crvec);
  381.  
  382.     if (f_dotl < 0)
  383.     {
  384.         if (f_dotr < 0)
  385.         {
  386.             spot45 = east;
  387.         }
  388.         else
  389.         {
  390.             spot45 = north;
  391.         }
  392.     }
  393.     else
  394.     {
  395.         if (f_dotr < 0)
  396.         {
  397.             spot45 = south;
  398.         }
  399.         else
  400.         {
  401.             spot45 = west;
  402.         }
  403.     }
  404.     
  405.     # continuous camera offset...
  406.     camindy = CreateThing(tpl_indy, player);
  407.     CaptureThing(camindy);
  408.     v_aimcam = VectorNorm(VectorSub(GetThingPos(centerspot), GetThingPos(camindy)));
  409.     v_aimcam = VectorNorm(VectorSet(VectorX(v_aimcam), VectorY(v_aimcam), 0.0));        
  410.     SetThingLook(camindy, v_aimcam);
  411.  
  412.     if (spot == spot45)
  413.     {
  414.         v_campos =
  415.         VectorAdd(VectorTransformToOrient(camindy, '0.21 0.06 0.19'), GetThingPos(camindy));
  416.     }
  417.     else
  418.     {
  419.         v_campos =
  420.         VectorAdd(VectorTransformToOrient(camindy, '-0.21 0.06 0.19'), GetThingPos(camindy));
  421.     }
  422.  
  423.     camsector = FindNewSectorFromThing(camindy, v_campos);
  424.     DestroyThing(camindy);
  425.     if (offcamexists != 0)
  426.     {
  427.         DestroyThing(offsetcam);
  428.         offcamexists = 0;
  429.     }
  430.     offsetcam = CreateThingAtPos(tpl_ghost, camsector, v_campos, '0 0 0');
  431.     CaptureThing(offsetcam);
  432.     offcamexists = 1;
  433.  
  434.     # **************************
  435.     # ** first visit cutscene **
  436.     # **************************
  437.  
  438.     if ((getinfo != 0) && (visits == 0) && (curItem == 0) && (playing == 0))
  439.     {
  440.         #### test only!
  441.         #### call fourWinds;
  442.         #### return;
  443.         
  444.         playing = 1;
  445.         visits = 1;
  446.         
  447.         # prep
  448.         MakeMeStop();
  449.         StartCutscene(1);
  450.         DeselectWeaponWait(player);       
  451.         indy = CreateThing(tpl_Indy, player);
  452.         CaptureThing(indy);
  453.         ClearThingFlags(indy, 0x80000);
  454.         SetCollideType(indy, 0);
  455.         CopyPlayerHolsters(player, indy);
  456.         SetThingAlpha(indy, 1.0);
  457.         SetThingFlags(player, 0x80000);
  458.  
  459.         AISetLookThing(indy, centerspot);
  460.  
  461.         # set cam
  462.         MakeCamera2LikeCamera1(camspot, camlookspot);
  463.         SetCameraFocus(2, camspot);
  464.         SetCameraSecondaryFocus(2, camlookspot);
  465.         SetCurrentCamera(2);
  466.         ResetCameraFOV(0, 0.0);
  467.         # Sleep(0.01);
  468.         SetCameraLookInterp(2, 1);
  469.         SetCameraPosInterp(2, 1);
  470.         SetCameraInterpSpeed(2, 0.8);
  471.         Sleep(0.01);
  472.         SetCameraFocus(2, offsetcam);
  473.         SetCameraSecondaryFocus(2, centerspot);
  474.         SetCameraFOV(98, 1, 0.8);
  475.         
  476.         if (lit_Count == 4)
  477.         {
  478.             cursound = PlayVoice(indy, say_worked, 1.0, 0);
  479.             PlayKey(indy, in_rtarmup, 4, 0x12, 1);
  480.             WaitForSound(cursound);
  481.         }
  482.         else
  483.         {
  484.             cursound = PlayVoice(indy, say_Candelabra, 1.0, 0); # 5.3s
  485.             in_keyTrack1 = PlayKey(indy, in_handsONhips, 2, 0x10, 0);
  486.             PlayKey(indy, in_sideTOhips, 4, 0x12, 1);
  487.             in_keyTrack2 = PlayKey(indy, in_think, 4, 0x12, 0);
  488.             WaitForSound(cursound);
  489.  
  490.             cursound = PlayVoice(indy, say_Pray1, 1.0, 0); # 2.4s
  491.             Sleep(2.0);
  492.             StopKey(indy, in_keyTrack1, 0.5);
  493.             StopKey(indy, in_keyTrack2, 0.5);
  494.             Sleep(0.5);
  495.         }
  496.         
  497.         # Clean up & restore controls
  498.         ClearThingFlags(player, 0x80000);
  499.         DestroyThing(indy);            
  500.         Call backtoplay;             
  501.         playing = 0;
  502.     }
  503.     
  504.     # *******************************
  505.     # ** subsequent visit cutscene **
  506.     # *******************************
  507.  
  508.     else if ((getinfo != 0) && (visits != 0) && (curItem == 0) && (playing == 0))
  509.     { 
  510.         playing = 1;
  511.         
  512.         # prep
  513.         MakeMeStop();
  514.         StartCutscene(1);
  515.         DeselectWeaponWait(player);
  516.         indy = CreateThing(tpl_Indy, player);
  517.         CaptureThing(indy);
  518.         ClearThingFlags(indy, 0x80000);
  519.         SetCollideType(indy, 0);
  520.         CopyPlayerHolsters(player, indy);
  521.         SetThingAlpha(indy, 1.0);
  522.         SetThingFlags(player, 0x80000);
  523.  
  524.         AISetLookThing(indy, centerspot);
  525.   
  526.         # set cam
  527.         MakeCamera2LikeCamera1(camspot, camlookspot);
  528.         SetCameraFocus(2, camspot);
  529.         SetCameraSecondaryFocus(2, camlookspot);
  530.         SetCurrentCamera(2);
  531.         ResetCameraFOV(0, 0.0);
  532.         SetCameraLookInterp(2, 1);
  533.         SetCameraPosInterp(2, 1);
  534.         SetCameraInterpSpeed(2, 0.8);
  535.         Sleep(0.01);
  536.         SetCameraFocus(2, offsetcam);
  537.         SetCameraSecondaryFocus(2, centerspot);
  538.         SetCameraFOV(98, 1, 0.8);
  539.  
  540.         if (lit_Count == 4)
  541.         {
  542.             cursound = PlayVoice(indy, say_worked, 1.0, 0);
  543.             PlayKey(indy, in_rtarmup, 4, 0x12, 1);
  544.             WaitForSound(cursound);
  545.         }
  546.         else
  547.         {
  548.             if (RandBetween(0,1) == 1)
  549.             {
  550.                 cursound = PlayVoice(indy, say_Pray1, 1.0, 0); # 2.4s
  551.                 PlayKey(indy, in_rtarmup, 4, 0x12, 1);
  552.                 WaitForSound(cursound);
  553.             }
  554.             else
  555.             {
  556.                 cursound = PlayVoice(indy, say_Pray2, 1.0, 0); # 3.3s
  557.                 Sleep(1.5);
  558.                 PlayKey(indy, in_botharmsup, 4, 0x12, 1);
  559.                 WaitForSound(cursound);
  560.             }
  561.         }
  562.         
  563.         # Clean up & restore controls
  564.         ClearThingFlags(player, 0x80000);
  565.         DestroyThing(indy);    
  566.         Call backtoplay;
  567.  
  568.         visits = visits + 1;
  569.         if (visits > 2)
  570.         {
  571.             visits = 0;
  572.         }
  573.         
  574.         playing = 0;
  575.     }
  576.     
  577.     # **********************
  578.     # ** candle placement **
  579.     # **********************
  580.  
  581.     else if ((sendid == 2) && (curItem != 0) && (playing == 0))
  582.     {        
  583.         # ** north holder **
  584.         if ((sender == candleArm_N) && (placed_N == 0))    
  585.         {        
  586.             if ((curItem >= 88) && (curItem <= 91))
  587.             {
  588.                 # player may use any candle on a holder
  589.                 placed_N = 1;
  590.                 spot = north;
  591.                 Call placecandle;    
  592.             }
  593.             else
  594.             {
  595.                 # player is using something other than a candle
  596.                 playing = 1;
  597.                 Call speak_Item;
  598.             }
  599.         }
  600.         
  601.         # ** south holder **
  602.         else if ((sender == candleArm_S) && (placed_S == 0))
  603.         {
  604.             if ((curItem >= 88) && (curItem <= 91))
  605.             {
  606.                 placed_S = 1;
  607.                 spot = south;
  608.                 Call placecandle;
  609.             }
  610.             else
  611.             {
  612.                 playing = 1;
  613.                 Call speak_Item;
  614.             }
  615.         }
  616.         
  617.         # ** east holder **
  618.         else if ((sender == candleArm_E) && (placed_E == 0))
  619.         {
  620.             if ((curItem >= 88) && (curItem <= 91))
  621.             {
  622.                 placed_E = 1;
  623.                 spot = east;
  624.                 Call placecandle;
  625.             }
  626.             else
  627.             {
  628.                 playing = 1;
  629.                 Call speak_Item;
  630.             }
  631.         }
  632.         
  633.         # ** west holder **
  634.         else if ((sender == candleArm_W) && (placed_W == 0))
  635.         {
  636.             if ((curItem >= 88) && (curItem <= 91))
  637.             {
  638.                 placed_W = 1;
  639.                 spot = west;
  640.                 Call placecandle;
  641.             }
  642.             else
  643.             {
  644.                 playing = 1;
  645.                 Call speak_Item;
  646.             }
  647.         }
  648.     }
  649.  
  650.     # ** NOT any holder **
  651.     else if (sender == candelabra)
  652.     {
  653.         
  654.         if ((curItem >= 88) && (curItem <= 91))
  655.         {   
  656.            # player is using a candle on wrong spot
  657.             playing = 1;
  658.             Call speak_Wrong;
  659.         }
  660.         else if (curWeap != 13) 
  661.         {                
  662.             # player is using something other than a candle
  663.             playing = 1;
  664.             Call speak_Item;
  665.         }
  666.     }
  667.     
  668.     # *********************
  669.     # ** candle ignition **
  670.     # *********************
  671.     
  672.     else if ((sender == candleArm_N) && (curWeap == 13) && (lit_CandleN == 0) && (placed_N == 1) && (playing == 0))
  673.     {
  674.         playing = 1;
  675.         spot = north;
  676.         Call lightcandle;
  677.     }
  678.     else if ((sender == candleArm_S) && (curWeap == 13) && (lit_CandleS == 0) && (placed_S == 1) && (playing == 0))
  679.     {
  680.         playing = 1;
  681.         spot = south;
  682.         Call lightcandle;
  683.     }
  684.     else if ((sender == candleArm_E) && (curWeap == 13) && (lit_CandleE == 0) && (placed_E == 1) && (playing == 0))
  685.     {
  686.         playing = 1;
  687.         spot = east;
  688.         Call lightcandle;
  689.     }
  690.     else if ((sender == candleArm_W) && (curWeap == 13) && (lit_CandleW == 0) && (placed_W == 1) && (playing == 0))
  691.     {
  692.         playing = 1;
  693.         spot = west;
  694.         Call lightcandle;
  695.     }
  696.  
  697.     return;
  698.     
  699. #===============================================================================
  700.  
  701. placecandle:
  702.  
  703.     # do cutscene stuff
  704.     MakeMeStop();
  705.     StartCutscene(2);
  706.     
  707.     # put away any weapon
  708.     DeselectWeaponWait(player);
  709.     
  710.     # prep
  711.     if (spot == north)
  712.     {        
  713.         offset_L = candleArm_N;
  714.         candlePos_X = candlePos_N;
  715.     }
  716.     if (spot == south)
  717.     {
  718.         offset_L = candleArm_S;
  719.         candlePos_X = candlePos_S;
  720.     }
  721.     if (spot == east)
  722.     {
  723.         offset_L = candleArm_E;
  724.         candlePos_X = candlePos_E;
  725.     }
  726.     if (spot == west)
  727.     {
  728.         offset_L = candleArm_W;
  729.         candlePos_X = candlePos_W;
  730.     }
  731.     
  732.     # slew camera
  733.     MakeCamera2LikeCamera1(camspot, camlookspot);
  734.     SetCameraFocus(2, camspot);
  735.     SetCameraSecondaryFocus(2, camlookspot);
  736.     SetCurrentCamera(2);
  737.     ResetCameraFOV(0, 0.0);
  738.     # SetCameraFOV(viewangle, 0, 0.0);
  739.     # Sleep(0.1);
  740.     SetCameraLookInterp(2, 1);
  741.     SetCameraPosInterp(2, 1);
  742.     SetCameraInterpSpeed(2, 0.8);
  743.     Sleep(0.1);
  744.     SetCameraFocus(2, offsetcam);
  745.     SetCameraSecondaryFocus(2, offset_L);
  746.     SetCameraFOV(98, 1, 0.8);
  747.    
  748.     # reach for candelabra
  749.     PlayMode(player, 60, 0);
  750.     Sleep(0.3);
  751.     
  752.     if (curItem == 88)
  753.     {
  754.         # candle A    
  755.         candleA = CreateThing(tpl_CandleA, candlePos_X);        
  756.         CaptureThing(candleA);
  757.         SetCollideType(candleA, 0);
  758.     
  759.         # remove candle A from inventory
  760.         ChangeInv(player, 88, -1);
  761.     }
  762.  
  763.     if (curItem == 89)
  764.     {
  765.         # candle B
  766.         candleB = CreateThing(tpl_CandleB, candlePos_X);            
  767.         CaptureThing(candleB);
  768.         SetCollideType(candleB, 0);
  769.  
  770.         ChangeInv(player, 89, -1);
  771.     }
  772.  
  773.     if (curItem == 90)
  774.     {
  775.         # candle C
  776.         candleC = CreateThing(tpl_CandleC, candlePos_X);
  777.         CaptureThing(candleC);
  778.         SetCollideType(candleC, 0);
  779.  
  780.         ChangeInv(player, 90, -1);
  781.     }
  782.  
  783.     if (curItem == 91)
  784.     {
  785.         # candle D    
  786.         candleD = CreateThing(tpl_CandleD, candlePos_X);
  787.         CaptureThing(candleD);
  788.         SetCollideType(candleD, 0);
  789.  
  790.         ChangeInv(player, 91, -1);
  791.     }
  792.  
  793.     placed_Count = placed_Count + 1;
  794.     
  795.     # play success line
  796.     call speak_Success;
  797.     
  798.     # restore controls
  799.     Call backtoplay;
  800.  
  801.     return;
  802.  
  803. #===============================================================================
  804.     
  805. lightcandle:
  806.  
  807.     # do cutscene stuff
  808.     MakeMeStop();
  809.     StartCutscene(1);
  810.     
  811.     # prep
  812.     if (spot == north)
  813.     {
  814.         lit_CandleN = 1;
  815.         offset_L = candleArm_N;
  816.         somecandlecog = northcandlecog;
  817.     }
  818.     if (spot == south)
  819.     {
  820.         lit_CandleS = 1;
  821.         offset_L = candleArm_S;
  822.         somecandlecog = southcandlecog;
  823.     }
  824.     if (spot == east)
  825.     {
  826.         lit_CandleE = 1;
  827.         offset_L = candleArm_E;
  828.         somecandlecog = eastcandlecog;
  829.     }
  830.     if (spot == west)
  831.     {
  832.         lit_CandleW = 1;
  833.         offset_L = candleArm_W;
  834.         somecandlecog = westcandlecog;
  835.     }
  836.     
  837.     # slew camera
  838.     MakeCamera2LikeCamera1(camspot, camlookspot);
  839.     SetCameraFocus(2, camspot);
  840.     SetCameraSecondaryFocus(2, camlookspot);
  841.     SetCurrentCamera(2);
  842.     ResetCameraFOV(0, 0.0);
  843.     # SetCameraFOV(viewangle, 0, 0.0);
  844.     # Sleep(0.1);
  845.     SetCameraLookInterp(2, 1);
  846.     SetCameraPosInterp(2, 1);
  847.     SetCameraInterpSpeed(2, 0.8);
  848.     Sleep(0.1);
  849.     SetCameraFocus(2, offsetcam);
  850.     SetCameraSecondaryFocus(2, offset_L);
  851.     SetCameraFOV(98, 1, 0.8);
  852.    
  853.     PlayMode(player, 60, 0);
  854.     Sleep(0.3);
  855.     
  856.     # light candle
  857.     SendMessage(somecandlecog, user1);
  858.  
  859.     if (placed_Count == 4)
  860.     {
  861.         # candles remain lit
  862.         lit_Count = lit_Count + 1;
  863.         if (lit_Count == 4)
  864.         {
  865.             call fourWinds;
  866.         }
  867.         else
  868.         {
  869.             Sleep(1.0);
  870.             Call backtoplay;
  871.         }
  872.  
  873.         playing = 0;
  874.     }
  875.     else
  876.     {
  877.         Sleep(1.0);
  878.         Call backtoplay;      
  879.         playing = 0;
  880.  
  881.         # blow out candle
  882.         SendMessage(somecandlecog, user2);
  883.     }
  884.  
  885.     return;
  886.  
  887. #===============================================================================
  888.  
  889. fourWinds:
  890.   
  891.     # Stop sector thrust...
  892.     SetSectorThrust(sec0, '0.0 0.0 0.0', 0.0);
  893.     
  894.     # solve hint40
  895.     SendMessage(hintCog, user0);
  896.     
  897.     # Prep...
  898.     MakeMeStop();
  899.     DeselectWeaponWait(player);
  900.     StartCutscene(2);
  901.     indy = CreateThing(tpl_Indy, player);
  902.     CaptureThing(indy);
  903.     ClearThingFlags(indy, 0x80000);
  904.     CopyPlayerHolsters(player, indy);
  905.     SetThingAlpha(indy, 1.0);
  906.     SetThingFlags(player, 0x80000);
  907.     SetCollideType(indy, 0);
  908.  
  909.     # Shot of kiosk & Indy...
  910.     SetCameraLookInterp(2, 0);
  911.     SetCameraPosInterp(2, 0);
  912.     SetCameraFocus(2, wm_cam_1);
  913.     SetCameraSecondaryFocus(2, wm_ct_1);
  914.     SetCurrentCamera(2);
  915.     SetCameraFOV(70, 0, 0.0);
  916.  
  917.     # music flourish
  918.     PlaySoundLocal(mus_Cue1, 1.0, 0.0, 0x0, 0);
  919.  
  920.     # Indy turns...
  921.     AISetLookThing(indy, windmill);
  922.     
  923.     # wind sounds
  924.     PlaySoundLocal(sfx_Gust1, 1.0, 0.0, 0x0, 0);
  925.     
  926.     # create wind-filled flags
  927.     wind_Flag1 = CreateThing(tpl_WindFlag, flag1);
  928.     CaptureThing(wind_Flag1);
  929.     wind_Flag2 = CreateThing(tpl_WindFlag, flag2);
  930.     CaptureThing(wind_Flag2);
  931.     Sleep(0.01);
  932.     DestroyThing(flag1);
  933.     DestroyThing(flag2);
  934.     
  935.     # animate the flags
  936.     PlayKey(wind_Flag1, key_Flag, 4, 0x10, 0);
  937.     PlayKey(wind_Flag2, key_Flag, 4, 0x10, 0);
  938.     
  939.     # create snow devils
  940.     CreateThing(tpl_Devil, devil0);
  941.     Sleep(0.2);
  942.     CreateThing(tpl_LilDevil, devil2);
  943.     Sleep(0.3);
  944.     
  945.     # Pan over toward windmill...
  946.     SetCameraLookInterp(2, 1);
  947.     SetCameraInterpSpeed(2, 3.0);
  948.     Sleep(0.01);
  949.     SetCameraSecondaryFocus(2, wm_ct_2);
  950.     Sleep(1.0);
  951.     
  952.     # TO DO: flap flags
  953.     
  954.     # more devils
  955.     CreateThing(tpl_Devil, devil1);
  956.     Sleep(0.2);
  957.     CreateThing(tpl_LilDevil, devil3);
  958.     
  959.     # more wind sounds
  960.     PlaySoundLocal(sfx_Gust1, 1.0, 0.0, 0x0, 0);
  961.     
  962.     Sleep(2.5);
  963.  
  964.     # Cut to windmill gears...
  965.     wm_colltype = GetCollideType(windmill);
  966.     t_colltype = GetCollideType(tower);
  967.     SetCollideType(windmill, 0);
  968.     SetCollideType(tower, 0);
  969.     SetCameraLookInterp(2, 0);
  970.     SetCameraFocus(2, wm_cam_2);
  971.     SetCameraSecondaryFocus(2, wm_ct_3);
  972.     SetCameraFOV(70, 0, 0.0);
  973.    
  974.     # Spin windmill...
  975.     wm_keyTrack1 = PlayKey(windmill, key_Gears, 4, 0x10, 0);
  976.     wm_sndTrack1= PlaySoundThing(sfx_Gears, windmill, 1.0, 4, 35, 0x881);
  977.     
  978.     # small wind sounds
  979.     PlaySoundLocal(sfx_Gust0, 1.0, 0.0, 0x0, 0);
  980.     
  981.     Sleep(1.5);
  982.     
  983.     # big wind sounds
  984.     PlaySoundLocal(sfx_Gust1, 1.0, 0.0, 0x0, 0);
  985.     
  986.     # pan up
  987.     SetCameraLookInterp(2, 1);
  988.     SetCameraInterpSpeed(2, 3.0);
  989.     Sleep(0.1);
  990.     SetCameraSecondaryFocus(2, wm_ct_4);
  991.     SetCameraFOV(45, 1, 3.0);
  992.     Sleep(3.2);
  993.     
  994.     # dolly back
  995.     SetCameraPosInterp(2, 1);
  996.     SetCameraInterpSpeed(2, 12.0);
  997.     Sleep(0.1);
  998.     SetCameraFocus(2, wm_cam_3);
  999.     SetCAmeraSecondaryFocus(2, wm_ct_3);
  1000.     SetCameraFOV(90, 1, 12.0);
  1001.     Sleep(6.0);
  1002.    
  1003.     # prep indy
  1004.     TeleportThing(indy, wm_mk_1);
  1005.     
  1006.     # create anim bridge
  1007.     bridge_Anim = CreateThing(tpl_BridgeAnim, bridge);
  1008.     CaptureThing(bridge_Anim);
  1009.     DestroyThing(bridge);
  1010.     Sleep(0.01);
  1011.     
  1012.     PlaySoundThing(sfx_Start, bridge_Anim, 1.0, 15, 35, 0x0);
  1013.     move_Track = PlaySoundThing(sfx_Move, bridge_Anim, 1.0, 15, 35, 0x881);
  1014.  
  1015.     # pivot bridge
  1016.     PlayKey(bridge_Anim, key_Bridge, 4, 0x14, 0);
  1017.     Sleep(4.0);
  1018.  
  1019.     # Indy into frame
  1020.     AISetMoveSpeed(indy, 0.9);
  1021.     AISetLookThingEyeLevel(indy, wm_mk_2);
  1022.     AISetMoveThing(indy, wm_mk_2, 0);   
  1023.     Sleep(2.0);
  1024.  
  1025.     StopSound(move_Track, 0.5);
  1026.     PlaySoundThing(sfx_Stop, bridge_Anim, 1.0, 15, 35, 0x0);
  1027.     AIWaitForStop(indy);
  1028.     AISetLookThingEyeLevel(indy, windmill);
  1029.     Sleep(0.5);
  1030.     
  1031.     ClearThingFlags(player, 0x80000);
  1032.     TeleportThing(player, indy);
  1033.     DestroyThing(indy);
  1034.     
  1035.     # clean up
  1036.     SetCollideType(windmill, wm_colltype);
  1037.     SetCollideType(tower, t_colltype);    
  1038.     SetCameraLookInterp(2, 0);
  1039.     SetCameraPosInterp(2, 0);            
  1040.     v_campos =
  1041.         VectorAdd(VectorTransformToOrient(player, '0.25 -0.05 0.05'), GetThingPos(player));    
  1042.     SetCameraPosition(1, v_campos);
  1043.     SetCurrentCamera(curcam);
  1044.     ResetCameraFOV(0, 0.0);
  1045.     RestoreExtCam();
  1046.     EndCutscene();
  1047.     ClearActorFlags(player, 0x200000);
  1048.     
  1049.     # create walkable bridge
  1050.     exit_Bridge = CreateThing(tpl_BridgeStill, bridge2);
  1051.     CaptureThing(exit_Bridge);
  1052.     DestroyThing(bridge_Anim);
  1053.     
  1054.     return;
  1055.  
  1056. #===============================================================================
  1057.  
  1058. endCut:
  1059.  
  1060.     # prep
  1061.     MakeMeStop();
  1062.     StartCutscene(2);
  1063.     DeselectWeaponWait(player);
  1064.     indy = CreateThing(tpl_Indy, player);
  1065.     CaptureThing(indy);
  1066.     ClearThingFlags(indy, 0x80000);
  1067.     CopyPlayerHolsters(player, indy);
  1068.     SetThingAlpha(indy, 1.0);
  1069.     SetThingFlags(player, 0x80000);
  1070.     AISetCutsceneMode(indy);
  1071.     
  1072.     # play endcut music cue
  1073.     PlaySoundLocal(mus_Cue2, 1.0, 0.0, 0x0, 0);
  1074.   
  1075.     # walk indy into sunset
  1076.     AISetMoveSpeed(indy, 1.0);
  1077.     AISetLookThingEyeLevel(indy, wm_mk_3);
  1078.     AISetMoveThing(indy, wm_mk_3, 0);
  1079.     
  1080.     # Cut to watch
  1081.     SetCameraLookInterp(2, 0);
  1082.     SetCameraPosInterp(2, 0);            
  1083.     SetCameraFocus(2, wm_cam_4);
  1084.     SetCameraSecondaryFocus(2, wm_ct_5);
  1085.     SetCurrentCamera(2);
  1086.     SetCameraFOV(75, 0, 0.0);
  1087.     
  1088.     # dolly behind
  1089.     SetCameraLookInterp(2, 1);
  1090.     SetCameraPosInterp(2, 1);            
  1091.     SetCameraInterpSpeed(2, 10.0);
  1092.     Sleep(0.01);
  1093.     SetCameraFocus(2, wm_cam_5);
  1094.     SetCameraSecondaryFocus(2, wm_ct_6);
  1095.     SetCameraFOV(80, 1, 10.0);            
  1096.     Sleep(5.0);
  1097.     
  1098.     # Indy "strange place for a wm"
  1099.     ChangeSoundVol(wm_sndTrack1, 0.3, 0.3);
  1100.     Sleep(0.2);
  1101.     PlayVoice(indy, say_Strange, 1.0, 0); # 1.4 sec
  1102.     Sleep(1.0);
  1103.     ChangeSoundVol(wm_sndTrack1, 0.8, 0.4);
  1104.     Sleep(4.5);
  1105.     AIWaitForStop(indy);
  1106.  
  1107.     # Cut to candles
  1108.     StopSound(wm_sndTrack1, 0.0);
  1109.     wm_sndTrack1= PlaySoundThing(sfx_Gears, windmill, 0.4, 45, 80, 0x881);
  1110.     SetCameraLookInterp(2, 0);
  1111.     SetCameraPosInterp(2, 0);            
  1112.     SetCameraFocus(2, offset_N);
  1113.     SetCameraSecondaryFocus(2, centerspot);
  1114.     SetCameraFOV(70, 0, 0.0);
  1115.     Sleep(0.01);
  1116.     SetCameraFOV(60, 1, 2.0);
  1117.     Sleep(1.0);
  1118.  
  1119.     # blow out candles
  1120.     PlaySoundLocal(sfx_Gust0, 1.0, 0.0, 0x0, 0);
  1121.     
  1122.     SendMessage(northcandlecog, user3);
  1123.     Sleep(0.2);
  1124.     SendMessage(eastcandlecog, user3);
  1125.     Sleep(0.1);
  1126.     SendMessage(westcandlecog, user3);
  1127.     Sleep(0.2);
  1128.     SendMessage(southcandlecog, user3);
  1129.     Sleep(1.0);
  1130.     
  1131.     # end here
  1132.     ClearThingFlags(fadeplate, 0x80000);    
  1133.     ThingFadeAnim(fadePlate, 0.0, 1.0, 1.0, 0);    
  1134.     StopSound(wm_sndTrack1, 1.0);  
  1135.     Sleep(2.0);    
  1136.     
  1137.     EndCutScene();
  1138.     JonesEndLevel();
  1139.  
  1140.     #### temp for debug only ## comment out before builds
  1141.     #ClearThingFlags(player, 0x80000);
  1142.     #DestroyThing(indy);
  1143.     #EndCutScene();
  1144.     #ClearActorFlags(player, 0x200000);
  1145.  
  1146.     return;
  1147.  
  1148. #===============================================================================
  1149.  
  1150. speak_Success:
  1151.  
  1152.     while (newSuccess == oldSuccess) 
  1153.     {
  1154.         newSuccess = RandBetween(0, 2);
  1155.     }
  1156.     
  1157.     oldSuccess = newSuccess;
  1158.  
  1159.     if (placed_Count == 4)
  1160.     {
  1161.         newSuccess = 3;
  1162.     }
  1163.     
  1164.     # say success line
  1165.     PlayVoice(player, in_Success0[newSuccess], 1.0, 1);
  1166.     
  1167.     return;
  1168.  
  1169.     
  1170. #===============================================================================
  1171.  
  1172. speak_Item:
  1173.  
  1174.     while (newItem == oldItem) 
  1175.     {
  1176.         newItem = RandBetween(0, 4);
  1177.     }
  1178.     
  1179.     oldItem = newItem;
  1180.     
  1181.     # do cutscene stuff
  1182.     MakeMeStop();
  1183.     StartCutscene(2);
  1184.     
  1185.     # put away any weapon
  1186.     DeselectWeaponWait(player);
  1187.     
  1188.     # reach for it
  1189.     PlayMode(player, 60, 0);
  1190.     Sleep(0.3);
  1191.     
  1192.     # say wrong item line
  1193.     PlayVoice(player, in_WrongItem0[newItem], 1.0, 1);
  1194.     
  1195.     # restore controls
  1196.     ClearActorFlags(player, 0x200000);
  1197.     EndCutscene();
  1198.     
  1199.     playing = 0;
  1200.     
  1201.     return;
  1202.  
  1203. #===============================================================================
  1204.  
  1205. speak_Wrong:
  1206.  
  1207.     while (newWrong == oldWrong) 
  1208.     {
  1209.         newWrong = RandBetween(0, 2);
  1210.     }
  1211.     
  1212.     oldWrong = newWrong;
  1213.     
  1214.     # do cutscene stuff
  1215.     MakeMeStop();
  1216.     StartCutscene(2);
  1217.     
  1218.     # put away any weapon
  1219.     DeselectWeaponWait(player);
  1220.     
  1221.     # reach for it
  1222.     # PlayMode(player, 60, 0);
  1223.     # Sleep(0.3);
  1224.     
  1225.     # say wrong spot line
  1226.     PlayVoice(player, in_WrongSpot0[newWrong], 1.0, 1);
  1227.     
  1228.     # restore controls
  1229.     ClearActorFlags(player, 0x200000);
  1230.     EndCutscene();
  1231.     
  1232.     playing = 0;
  1233.     
  1234.     return;
  1235.  
  1236. #===============================================================================
  1237.  
  1238. backtoplay:
  1239.  
  1240.     SetCameraInterpSpeed(2, 0.6);
  1241.     SetCameraFocus(2, camspot);
  1242.     SetCameraSecondaryFocus(2, camlookspot);
  1243.     SetCameraFOV(viewangle, 1, 0.6);
  1244.     Sleep(0.65);
  1245.     SetCurrentCamera(curcam);
  1246.     ResetCameraFOV(0, 0.0);
  1247.     SetCameraLookInterp(2, 0);
  1248.     SetCameraPosInterp(2, 0);
  1249.     EndCutscene();
  1250.     ClearActorFlags(player, 0x200000);
  1251.  
  1252.  return;
  1253.  
  1254. end
  1255.